package com.ruoyi.tranShort.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tranShort.domain.ShortSchedulingDate;
import com.ruoyi.tranShort.service.IShortSchedulingDateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排班日期Controller
 * 
 * @author ruoyi
 * @date 2021-08-14
 */
@RestController
@RequestMapping("/tranShort/schedulingDate")
public class ShortSchedulingDateController extends BaseController
{
    @Autowired
    private IShortSchedulingDateService shortSchedulingDateService;

    /**
     * 查询排班日期列表
     */
    @PreAuthorize("@ss.hasPermi('tranShort:schedulingDate:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShortSchedulingDate shortSchedulingDate)
    {
        startPage();
        List<ShortSchedulingDate> list = shortSchedulingDateService.selectShortSchedulingDateList(shortSchedulingDate);
        return getDataTable(list);
    }

    /**
     * 导出排班日期列表
     */
    @PreAuthorize("@ss.hasPermi('tranShort:schedulingDate:export')")
    @Log(title = "排班日期", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShortSchedulingDate shortSchedulingDate)
    {
        List<ShortSchedulingDate> list = shortSchedulingDateService.selectShortSchedulingDateList(shortSchedulingDate);
        ExcelUtil<ShortSchedulingDate> util = new ExcelUtil<ShortSchedulingDate>(ShortSchedulingDate.class);
        return util.exportExcel(list, "排班日期数据");
    }

    /**
     * 获取排班日期详细信息
     */
    @PreAuthorize("@ss.hasPermi('tranShort:schedulingDate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shortSchedulingDateService.selectShortSchedulingDateById(id));
    }

    /**
     * 新增排班日期
     */
    @PreAuthorize("@ss.hasPermi('tranShort:schedulingDate:add')")
    @Log(title = "排班日期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShortSchedulingDate shortSchedulingDate)
    {
        return toAjax(shortSchedulingDateService.insertShortSchedulingDate(shortSchedulingDate));
    }

    /**
     * 修改排班日期
     */
    @PreAuthorize("@ss.hasPermi('tranShort:schedulingDate:edit')")
    @Log(title = "排班日期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShortSchedulingDate shortSchedulingDate)
    {
        return toAjax(shortSchedulingDateService.updateShortSchedulingDate(shortSchedulingDate));
    }

    /**
     * 删除排班日期
     */
    @PreAuthorize("@ss.hasPermi('tranShort:schedulingDate:remove')")
    @Log(title = "排班日期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shortSchedulingDateService.deleteShortSchedulingDateByIds(ids));
    }
}
